package com.sky.controller.test1;

public class Test12 {
    public static void main(String[] args) {
        String a = "111";//堆里面的常量池中
        String a1 = new String("111");//堆内存中
        char[] a2 = {'1','2','3'};
        String a3 = new String(a2);
        byte[] a4 = {97,65,66};
        String a5 = new String(a4);
        System.out.println(a+a1+a3+a5);
        if(a.equals(a1)){
            System.out.println(111);
        }
        //substring字符串截取
        System.out.println(Test12.getCode());
    }
    //封装一个验证码,六位数,每位可能是数字,大小写字母
    public static String getCode(){
        String code = "";
        for (int i = 0; i < 6; i++) {
            int num = (int)(Math.random()*3);
            switch (num){
                case 0:
                    code += (char)(Math.random()*26+65);
                    break;
                case 1:
                    code += (char)(Math.random()*26+97);
                    break;
                case 2:
                    code += (int)(Math.random()*10);
                   break;
            }
        }
        return code;
    }
}
